package authinterceptor

import (
	"context"
	"vpn-management-server/network"
	"vpn-management-server/src/service/authservice"
)

func AuthSession(ctx context.Context, request *network.NetRequest, response *network.NetResponse) bool {
	if request.Type == "admin" && request.Command == "login" {
		return true
	} else {
		return authservice.AuthSession(ctx, request, response)
	}
}

func UserAuthSession(ctx context.Context, request *network.NetRequest, response *network.NetResponse) bool {
	if request.Command == "login" || request.Command == "register" || request.Command == "tokenRegister" || request.Command == "tokenLogin" || request.Command == "reset" || request.Command == "getUserRule" || request.Command == "deleteUserByName" || request.Command == "singleLogin" || request.Command == "simAuth" || request.Command == "simAuthStatus" {
		return true
	} else {
		return authservice.AuthSession(ctx, request, response)
	}
}

func UserLogAuthSession(ctx context.Context, request *network.NetRequest, response *network.NetResponse) bool {
	if request.Command == "upLoadNormalLog" || request.Command == "upLoadWaringLog" {
		return true
	} else {
		return authservice.AuthSession(ctx, request, response)
	}
}

func VpnAuthSession(ctx context.Context, request *network.NetRequest, response *network.NetResponse) bool {
	if request.Command == "getVpnServerInfoByUserName" {
		return true
	} else {
		return authservice.AuthSession(ctx, request, response)
	}
}

func RuleAuthSession(ctx context.Context, request *network.NetRequest, response *network.NetResponse) bool {
	if request.Command == "getUserRule" {
		return true
	} else {
		return authservice.AuthSession(ctx, request, response)
	}
}
